Skip to content

Preserve the mean-field weight parameter during normalization - #813

Closed
AHMETHAKANBEZIR1 wants to merge 3 commits into
BindsNET:masterfrom
AHMETHAKANBEZIR1:fix/meanfield-normalization-parameter
Closed

AHMETHAKANBEZIR1 wants to merge 3 commits into
BindsNET:masterfrom
AHMETHAKANBEZIR1:fix/meanfield-normalization-parameter

Conversation

@AHMETHAKANBEZIR1

@AHMETHAKANBEZIR1 AHMETHAKANBEZIR1 commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

MeanFieldConnection.normalize replaces its registered Parameter with a reshaped tensor and crashes for shared and per-target weights. Scale the existing Parameter in place, preserving its identity, shape and state_dict registration.

Apply the normalization requested in review: norm is the total absolute weight across target neurons. Divide by the sum of absolute values to preserve inhibitory signs and prevent cancellation, and count a shared scalar once per target neuron. With three targets and norm=2, both a shared weight of 0.25 and the equivalent per-target vector normalize to 2/3 at every target. Zero weights remain finite. Constructor and method documentation now use this convention.

The branch includes master 78ec02b, including the merged #814 kernel-normalization change; the changelog conflict was resolved with all entries retained.

Validation on Windows CPU, Python 3.12 / Torch 2.14.0:

  • The updated review cases fail 10 times on the preceding implementation, with 17 passing controls; all 27 cases pass after the revision.
  • Complete standalone suite: 282 passed, 1 skipped. Coverage includes negative and cancelling weights, shared/per-target compute equivalence, repeated normalization, zero and disabled norms, Parameter identity and Network.run.
  • Private integration with Reset and resize CSRM connection spike history #815 and Forward mean-field learning rule options by name #816: 297 passed, 1 skipped. The changes applied cleanly apart from retaining each changelog entry. This is compatibility evidence, not a requirement to merge the PRs together.
  • Configured isort/Black hooks and diff checks passed. The five current-head GitHub checks succeeded. CUDA and timing measurements were not run locally.

AI disclosure: OpenAI Codex autonomously prepared and tested this contribution, including the requested revision. The account owner has not independently reviewed the code. No personal production incident or task-accuracy improvement is claimed.

@Hananel-Hazan Hananel-Hazan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi AhmetHakanBezir,

Thank you for using BindsNET and for opening this PR. The crash fix is right: on master, normalize() fails in every case I tried, and with your change the weight stays the same registered parameter. A couple of things need to change before it can merge. I measured each of them on your branch:

  1. Negative weights flip sign. The code divides by the plain sum of the weights, and the sum of negative weights is negative. With norm=2, weights [-1, -2] become [0.67, 1.33]. With norm=1, a shared weight of -0.5 becomes 1.0. An inhibitory connection silently becomes an excitatory one.
  2. Weights become infinite when their signs cancel. [1, -1] becomes [inf, -inf], and [1, -0.999999] becomes about [986895, -986894]. The guard only handles weights that are all zero.
  3. A shared weight and per-neuron weights give different results. For 3 target neurons and norm=2, a shared weight of 0.25 becomes 2.0, but per-neuron weights [0.25, 0.25, 0.25] become 0.67 each. That is the same network, with three times more input in one case.

Please divide by the sum of the absolute values, which is what Connection.normalize already does, and count a shared weight once for each target neuron:

if self.norm is not None:
    # A scalar weight is shared by every target neuron.
    total = self.w.abs().sum() * (self.target.n / self.w.numel())
    self.w *= self.norm / total.masked_fill(total == 0, 1)

I tried this on your branch:

  • signs stay the same ([-1, -2] becomes [-0.67, -1.33]);
  • [1, -1] stays [1, -1];
  • the shared and per-neuron cases now agree at 0.67;
  • it runs on GPU with no extra synchronization, at the same speed as your version.

Your three shared-weight tests expect norm itself and will need the new expected values.

Also:

  • Add tests for negative weights, for mixed-sign weights that sum to zero, and for a shared weight compared with an equal per-neuron vector.
  • Update the norm description in __init__, which still says "Total weight per target neuron", so it matches the new docstring.
  • Rebase on master when it's ready; the changelog entry will need a small conflict fix.

AHMETHAKANBEZIR1 and others added 3 commits October 23, 2026 04:47
Co-authored-by: OpenAI Codex <codex@openai.com>
Co-authored-by: OpenAI Codex <codex@openai.com>
Co-authored-by: OpenAI Codex <codex@openai.com>
@AHMETHAKANBEZIR1

Copy link
Copy Markdown
Contributor Author

Implemented in 53dd2e3: normalization uses the absolute weight total, counts a shared weight once per target neuron, preserves inhibitory signs, and keeps zero/cancelling weights finite. The constructor documentation and regression expectations are updated, and the branch includes master 78ec02b.

All 27 mean-field tests pass; the full CPU suite has 282 passes and 1 skip. All five current-head CI checks are green. CUDA and timing were not measured locally.

Hananel-Hazan added a commit that referenced this pull request Oct 29, 2026
…, CODEOWNERS (#828)

* test: golden-output and invariant regression tests, all-class smoke tests, API snapshot, coverage floor, PR template

Phases 1-4, 6, 7 of the test hardening plan (logs/test_hardening_2026-10/PLAN.md).

- test/regression/: 16 seeded networks ported from the review canaries; golden
  spike/voltage/trace/weight files (spikes exact, floats atol 1e-6, skipped on a
  different torch major.minor); invariants (split run, reset vs fresh, state_dict
  round trip, learning off, batch of copies, dt scaling). 100 passed, 15 strict xfail
  for known bugs (rule state outside state_dict, MulticompartmentConnection weights
  not saved, CSRM s_w window, PR #813 and #815 crashes).
- test/network/test_all_classes.py: every Nodes, connection, learning rule, feature
  and model class built and run; 25 strict xfail pin known crashes. Core coverage
  network 79-90% -> 91%, learning 84-87% -> 95%, models 43% -> 99%.
- test/test_api_surface.py + api_surface.json: public signatures pinned; regen
  scripts refuse to run without --reason.
- CI: pytest-cov in dev group, coverage floor script (network 90, learning 94),
  coverage.xml artifact.
- CONTRIBUTING.md, PR template, test/regression/README.md,
  bindsnet/learning/README.md known limitations.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* test: operation-count tests and A/B timing workflow (Phase 5)

- test/regression/test_op_counts.py + op_counts.json: kernel dispatch counts for one
  update() of every learning rule (batch 1 and 4), one DiehlAndCook2015 step
  (batch 1 and 16) and LIFNodes.forward; fails when a count grows, warns on a drop.
  regen_op_counts.py refuses without --reason. 32 tests, 3.9 s.
- .github/workflows/bench.yml + scripts/bench_ab.py: non-required PR workflow,
  merge base vs head, alternating rounds, median ratio with bootstrap interval,
  SLOWER above 1.25; report in the job summary and an artifact. Local no-change
  run: medians 0.965 to 1.012; a 0.5 ms/step sleep flagged on all workloads.
  Calibration on GitHub runners still pending.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* ci: test guard (fails-before-fix and weakened-tests checks) and CODEOWNERS

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* ci: weakened-tests also checks helper functions and tolerance constants; document the guard checks

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* ci: coverage floors from the first GitHub CI measurement (network 90.6%, learning 95.2%)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Hananel-Hazan added a commit that referenced this pull request Oct 29, 2026
* fix: IzhikevichNodes and CSRMNodes accept multi-dimensional shapes; CSRMNodes reset clears its spike window

IzhikevichNodes sized its parameters by the n argument (None when only shape is
given) and never reshaped them; CSRMNodes contracted with 'i,kij->kj'. Both now
work for any shape; one-dimensional results are bit-identical (goldens
conv2d_if_izh and csrm_window trial 0 unchanged). CSRMNodes.reset_state_variables
now zeroes last_spikes, which changes results after a reset (csrm_window
golden regenerated with that reason).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: LocalConnection batch > 1; MaxPool connections without decay or with one channel

LocalConnection.compute dropped the batch dimension in its final view.
MaxPool{1,2,3}d multiplied a missing decay (None) and squeeze()d away a channel
of size 1; a missing decay now means plain spike counts, and the firing-rate
buffer follows the spike tensor's shape. Results that ran before are unchanged
(goldens pass). Reproducers kept as test_fixed_bug_stays_fixed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: sparse MulticompartmentConnection learns and runs with batch > 1; NetworkMonitor reset; tuple target shapes

- MCC_LearningRule bounded sparse weights into a new tensor that only the rule
  held, so DiehlAndCook2015(sparse=True) never learned; the bound and the
  sparse normalisation now write in place. At batch 1 sparse and dense learn
  bit-identical weights without norm (test_sparse_dc2015_learns_like_dense);
  with norm they differ by summation order (max 6.0e-8).
- MulticompartmentConnection.compute applies per-sample sparse weight copies
  ([batch, src, tgt]) with bmm; one copy keeps the old arithmetic.
- NetworkMonitor.reset_state_variables looked connections up in layers.
- [batch] + target.shape failed for tuple shapes.

Results change: DiehlAndCook2015(sparse=True) now learns.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: MSTDP/MSTDPET/Rmax state cleared on reset; Rmax and MCC MSTDPET work with batch > 1

- LearningRule.reset_state_variables deletes the tensors a rule creates on its
  first update (_step_state); AbstractConnection.reset_state_variables forwards
  to the rule. Reset then equals a freshly built network (invariant tests for
  mstdp_mstdpet and rules_mix now pass). Results change after a reset with
  learning on: goldens mstdp_mstdpet(_dt05), rules_mix(_dt05) regenerated,
  trial 0 bit-identical.
- Rmax and MCC_learning.MSTDPET keep per-sample state and reduce the update
  over the batch, as MSTDP does. Batch 1 is bit-identical to the old formula
  (TestMccMstdpetBatched, goldens); batch 2 with sum equals the sum of single
  samples to summation order. Op counts at batch 1: MCC MSTDPET 24 -> 27,
  Rmax 24 -> 26 (regenerated with reason). API snapshot: +1 method.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: preserve the mean-field weight parameter during normalization (#813)

Adopted from #813 (head 53dd2e3) by AHMETHAKANBEZIR1, reviewed with the
bindsnet-pr-review skill (sandboxed canaries, fail-then-pass, API, timing);
Hananel adopted it as accountable author because the PR says no human
reviewed it. MeanFieldConnection.normalize scales w in place by norm over the
absolute weight sum (a shared scalar counted once per target), instead of
assigning a plain tensor to the Parameter (TypeError on every call).

Co-Authored-By: Hananel Hazan <hananel@hazan.org.il>
Co-Authored-By: OpenAI Codex <codex@openai.com>

* fix: reset and resize the CSRM connection spike history (#815)

Adopted from #815 (head 49c57f8) by AHMETHAKANBEZIR1, reviewed with the
bindsnet-pr-review skill; Hananel adopted it as accountable author because the
PR says no human reviewed it. Connection.compute_window re-creates s_w when the
batch size changes, and reset_state_variables clears it for CSRM targets.

Co-Authored-By: Hananel Hazan <hananel@hazan.org.il>
Co-Authored-By: OpenAI Codex <codex@openai.com>

* test: goldens and invariants after adopting #813 and #815

meanfield_norm and csrm_window goldens regenerated (both used to record a
crash). Invariant xfails removed: reset-equals-fresh for csrm_window and
meanfield_norm, round trip and batch for meanfield_norm. Still open: the CSRM
spike window is not in the state_dict (round trip).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: CSRM spike window saved in the state_dict; MulticompartmentConnection drives CSRMNodes

- Connection.s_w is a registered buffer, so state_dict saves it; a load adopts
  a saved window or drops one the saved state lacked (_load_window). The
  csrm_window round-trip invariant now passes; golden regenerated (adds s_w,
  no value changed).
- MulticompartmentConnection.compute_window read s_w and self.w, neither of
  which it has, so MCC into CSRMNodes always raised. It now keeps a window of
  its own outputs (pipeline runs once per step), resized on a batch change,
  cleared on reset, saved in the state_dict. With static weights it matches a
  Connection bit for bit (test_multicompartment_into_csrm_matches_connection).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: MeanFieldConnection keeps batch samples apart and applies weight_decay

- compute() took the mean over the whole batch, so one sample's input depended
  on the others; it now uses each sample's own mean (batch 1 bit-identical:
  goldens pass without the weight_decay change).
- weight_decay was passed by position into AbstractConnection's reduction
  slot and ignored; it is now passed by name. Results change for anyone who
  set weight_decay on a MeanFieldConnection (golden meanfield_decay
  regenerated with that reason).
- Two #813 test lines expected the batch-wide mean (0.75); corrected to the
  per-sample means.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: MeanField feature, Normalization/Updating sub-features, adaptation features at batch > 1, sparse weight bounds

- topology_features.MeanField never called the base constructor (no name) and
  had no initial value; it now has an optional name, a placeholder value, and
  a per-sample mean ([batch, src, tgt], applied per sample by compute).
- Sub-features (Normalization, Updating) get no-op prime_feature, update,
  normalize and reset_state_variables, which MulticompartmentConnection calls
  on every pipeline entry; both now work in the constructor and in Network.run.
- AdaptationBaseSynapsHistory/OtherSynaps: a synapse is active when its
  pre-synaptic neuron spiked in any sample (the mask is shared connectivity);
  batch 1 gives the same values.
- Sparse weights with wmin/wmax: Connection.__init__ bounds a dense copy,
  LearningRule.update bounds in place via a dense copy, and
  WeightDependentPostPre/DiehlAndCook compute their factors from a dense view.
  PostPre, WeightDependentPostPre and DiehlAndCook on a bounded
  SparseConnection learn bit-identical weights to the dense Connection.
- Test workarounds for these bugs removed (batch-1-only sets, broken pairs,
  tuple-shape and sparse-bound special cases).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test: known-bug list becomes FIXED_BUGS; workarounds removed; MulticompartmentConnection feature values in the state_dict

- MulticompartmentConnection saves its pipeline feature values as
  feature.<name> and loads them in place, so DiehlAndCook2015 can be saved
  and restored (the last four strict xfails in test_invariants.py now pass;
  dc2015 goldens regenerated: new keys, no value changed).
- Every KNOWN_BUGS entry is fixed: the dict becomes FIXED_BUGS (reproducers
  that must keep running); the empty xfail machinery in test_invariants.py and
  the batch-1, no-learning-check and sub-feature workarounds in
  test_all_classes.py are removed, so those classes run at batch 2 with full
  checks.
- CONTRIBUTING, PR template and bindsnet/learning/README.md updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: CHANGELOG for the 0.3.5 bug fixes, results changes listed first

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: issues found by independent review of PR #831

Network (reviewer B):
- MulticompartmentConnection state_dict: refuses to save duplicate feature
  names (they shared one key, and loading put one feature's value into the
  other); checks shape and sparse layout on load (copy_ broadcast a wrong-shaped
  tensor silently); saves the adaptation features' mask, spike buffer and
  counter (only value was saved).
- An Updating sub-feature drives its parent's learning; the connection's
  update skips that parent (it learned twice per step).
- A sub-feature whose parent is not in the pipeline is refused at construction
  (it failed later with an unclear TypeError). insert_pipeline had list.insert's
  arguments swapped.
- Connection.compute_window and MaxPool resets create state on the spikes'
  device (CUDA device mismatch, also on master).
- Docstrings state how the two CSRM windows differ once weights learn.

Learning rules (reviewer A):
- MCC_learning.DiehlAndCook crashed on sparse weights (twin of the learning.py
  fix). Sparse MCC weight copies now all get the batch's shared update in
  PostPre, DiehlAndCook and MSTDPET (as MSTDP did), so sparse equals dense; the
  default squeeze reduction means a sum over a larger batch, as in the fused
  dense path (_reduce_batch, _add_to_feature).
- Docs: per-sample reward shape [batch, 1, 1]; reset keeps the reduction chosen
  at construction.

CHANGELOG: checkpoint compatibility (strict=False for old checkpoints), new
state shapes, sparse and Updating semantics. Each fix has a test that fails on
ce98f93 and passes here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: AHMETHAKANBEZIR1 <ahmethakan0008@gmail.com>
Co-authored-by: OpenAI Codex <codex@openai.com>
Hananel-Hazan added a commit that referenced this pull request Oct 29, 2026
* fix: IzhikevichNodes and CSRMNodes accept multi-dimensional shapes; CSRMNodes reset clears its spike window

IzhikevichNodes sized its parameters by the n argument (None when only shape is
given) and never reshaped them; CSRMNodes contracted with 'i,kij->kj'. Both now
work for any shape; one-dimensional results are bit-identical (goldens
conv2d_if_izh and csrm_window trial 0 unchanged). CSRMNodes.reset_state_variables
now zeroes last_spikes, which changes results after a reset (csrm_window
golden regenerated with that reason).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: LocalConnection batch > 1; MaxPool connections without decay or with one channel

LocalConnection.compute dropped the batch dimension in its final view.
MaxPool{1,2,3}d multiplied a missing decay (None) and squeeze()d away a channel
of size 1; a missing decay now means plain spike counts, and the firing-rate
buffer follows the spike tensor's shape. Results that ran before are unchanged
(goldens pass). Reproducers kept as test_fixed_bug_stays_fixed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: sparse MulticompartmentConnection learns and runs with batch > 1; NetworkMonitor reset; tuple target shapes

- MCC_LearningRule bounded sparse weights into a new tensor that only the rule
  held, so DiehlAndCook2015(sparse=True) never learned; the bound and the
  sparse normalisation now write in place. At batch 1 sparse and dense learn
  bit-identical weights without norm (test_sparse_dc2015_learns_like_dense);
  with norm they differ by summation order (max 6.0e-8).
- MulticompartmentConnection.compute applies per-sample sparse weight copies
  ([batch, src, tgt]) with bmm; one copy keeps the old arithmetic.
- NetworkMonitor.reset_state_variables looked connections up in layers.
- [batch] + target.shape failed for tuple shapes.

Results change: DiehlAndCook2015(sparse=True) now learns.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: MSTDP/MSTDPET/Rmax state cleared on reset; Rmax and MCC MSTDPET work with batch > 1

- LearningRule.reset_state_variables deletes the tensors a rule creates on its
  first update (_step_state); AbstractConnection.reset_state_variables forwards
  to the rule. Reset then equals a freshly built network (invariant tests for
  mstdp_mstdpet and rules_mix now pass). Results change after a reset with
  learning on: goldens mstdp_mstdpet(_dt05), rules_mix(_dt05) regenerated,
  trial 0 bit-identical.
- Rmax and MCC_learning.MSTDPET keep per-sample state and reduce the update
  over the batch, as MSTDP does. Batch 1 is bit-identical to the old formula
  (TestMccMstdpetBatched, goldens); batch 2 with sum equals the sum of single
  samples to summation order. Op counts at batch 1: MCC MSTDPET 24 -> 27,
  Rmax 24 -> 26 (regenerated with reason). API snapshot: +1 method.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: preserve the mean-field weight parameter during normalization (#813)

Adopted from #813 (head 53dd2e3) by AHMETHAKANBEZIR1, reviewed with the
bindsnet-pr-review skill (sandboxed canaries, fail-then-pass, API, timing);
Hananel adopted it as accountable author because the PR says no human
reviewed it. MeanFieldConnection.normalize scales w in place by norm over the
absolute weight sum (a shared scalar counted once per target), instead of
assigning a plain tensor to the Parameter (TypeError on every call).

Co-Authored-By: Hananel Hazan <hananel@hazan.org.il>
Co-Authored-By: OpenAI Codex <codex@openai.com>

* fix: reset and resize the CSRM connection spike history (#815)

Adopted from #815 (head 49c57f8) by AHMETHAKANBEZIR1, reviewed with the
bindsnet-pr-review skill; Hananel adopted it as accountable author because the
PR says no human reviewed it. Connection.compute_window re-creates s_w when the
batch size changes, and reset_state_variables clears it for CSRM targets.

Co-Authored-By: Hananel Hazan <hananel@hazan.org.il>
Co-Authored-By: OpenAI Codex <codex@openai.com>

* test: goldens and invariants after adopting #813 and #815

meanfield_norm and csrm_window goldens regenerated (both used to record a
crash). Invariant xfails removed: reset-equals-fresh for csrm_window and
meanfield_norm, round trip and batch for meanfield_norm. Still open: the CSRM
spike window is not in the state_dict (round trip).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: CSRM spike window saved in the state_dict; MulticompartmentConnection drives CSRMNodes

- Connection.s_w is a registered buffer, so state_dict saves it; a load adopts
  a saved window or drops one the saved state lacked (_load_window). The
  csrm_window round-trip invariant now passes; golden regenerated (adds s_w,
  no value changed).
- MulticompartmentConnection.compute_window read s_w and self.w, neither of
  which it has, so MCC into CSRMNodes always raised. It now keeps a window of
  its own outputs (pipeline runs once per step), resized on a batch change,
  cleared on reset, saved in the state_dict. With static weights it matches a
  Connection bit for bit (test_multicompartment_into_csrm_matches_connection).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: MeanFieldConnection keeps batch samples apart and applies weight_decay

- compute() took the mean over the whole batch, so one sample's input depended
  on the others; it now uses each sample's own mean (batch 1 bit-identical:
  goldens pass without the weight_decay change).
- weight_decay was passed by position into AbstractConnection's reduction
  slot and ignored; it is now passed by name. Results change for anyone who
  set weight_decay on a MeanFieldConnection (golden meanfield_decay
  regenerated with that reason).
- Two #813 test lines expected the batch-wide mean (0.75); corrected to the
  per-sample means.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: MeanField feature, Normalization/Updating sub-features, adaptation features at batch > 1, sparse weight bounds

- topology_features.MeanField never called the base constructor (no name) and
  had no initial value; it now has an optional name, a placeholder value, and
  a per-sample mean ([batch, src, tgt], applied per sample by compute).
- Sub-features (Normalization, Updating) get no-op prime_feature, update,
  normalize and reset_state_variables, which MulticompartmentConnection calls
  on every pipeline entry; both now work in the constructor and in Network.run.
- AdaptationBaseSynapsHistory/OtherSynaps: a synapse is active when its
  pre-synaptic neuron spiked in any sample (the mask is shared connectivity);
  batch 1 gives the same values.
- Sparse weights with wmin/wmax: Connection.__init__ bounds a dense copy,
  LearningRule.update bounds in place via a dense copy, and
  WeightDependentPostPre/DiehlAndCook compute their factors from a dense view.
  PostPre, WeightDependentPostPre and DiehlAndCook on a bounded
  SparseConnection learn bit-identical weights to the dense Connection.
- Test workarounds for these bugs removed (batch-1-only sets, broken pairs,
  tuple-shape and sparse-bound special cases).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test: known-bug list becomes FIXED_BUGS; workarounds removed; MulticompartmentConnection feature values in the state_dict

- MulticompartmentConnection saves its pipeline feature values as
  feature.<name> and loads them in place, so DiehlAndCook2015 can be saved
  and restored (the last four strict xfails in test_invariants.py now pass;
  dc2015 goldens regenerated: new keys, no value changed).
- Every KNOWN_BUGS entry is fixed: the dict becomes FIXED_BUGS (reproducers
  that must keep running); the empty xfail machinery in test_invariants.py and
  the batch-1, no-learning-check and sub-feature workarounds in
  test_all_classes.py are removed, so those classes run at batch 2 with full
  checks.
- CONTRIBUTING, PR template and bindsnet/learning/README.md updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: CHANGELOG for the 0.3.5 bug fixes, results changes listed first

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: issues found by independent review of PR #831

Network (reviewer B):
- MulticompartmentConnection state_dict: refuses to save duplicate feature
  names (they shared one key, and loading put one feature's value into the
  other); checks shape and sparse layout on load (copy_ broadcast a wrong-shaped
  tensor silently); saves the adaptation features' mask, spike buffer and
  counter (only value was saved).
- An Updating sub-feature drives its parent's learning; the connection's
  update skips that parent (it learned twice per step).
- A sub-feature whose parent is not in the pipeline is refused at construction
  (it failed later with an unclear TypeError). insert_pipeline had list.insert's
  arguments swapped.
- Connection.compute_window and MaxPool resets create state on the spikes'
  device (CUDA device mismatch, also on master).
- Docstrings state how the two CSRM windows differ once weights learn.

Learning rules (reviewer A):
- MCC_learning.DiehlAndCook crashed on sparse weights (twin of the learning.py
  fix). Sparse MCC weight copies now all get the batch's shared update in
  PostPre, DiehlAndCook and MSTDPET (as MSTDP did), so sparse equals dense; the
  default squeeze reduction means a sum over a larger batch, as in the fused
  dense path (_reduce_batch, _add_to_feature).
- Docs: per-sample reward shape [batch, 1, 1]; reset keeps the reduction chosen
  at construction.

CHANGELOG: checkpoint compatibility (strict=False for old checkpoints), new
state shapes, sparse and Updating semantics. Each fix has a test that fails on
ce98f93 and passes here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* ci: close test-guard bypasses found by independent review (WIP part 1)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test: op-count workloads for every Nodes class

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* ci: close the test-guard bypasses found by independent review (part 2), docs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: AHMETHAKANBEZIR1 <ahmethakan0008@gmail.com>
Co-authored-by: OpenAI Codex <codex@openai.com>
@Hananel-Hazan

Copy link
Copy Markdown
Collaborator

Thank you. This fix is now in master as part of #831 (commit d48dc79), which fixed all known bugs for 0.3.5. You are credited as co-author on that commit. The fix will ship in release 0.3.5. Closing, because the change is merged through #831.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants